<template>
  <master :title="title">
    <listpage ref="listpage"></listpage>
  </master>
</template>
<script type="text/javascript">
(function (G) {
var _this = null;
G.vue({
  "usingComponents": {///引入组件
    "master": "/components/Master/Master",///母版组件
    "listpage": "/components/List/Page/Page",///通用列表组件
    "modal":"/components/Modal/Modal"
  },
  "enablePullDownRefresh": true
},G.modelList({
  	modelName:'job',
    title:'任务',
    listPage(list,query){
      list.getUrl = '/api/model/job?join=pject'
      list.edit.status = '/v1/job/toggle'
      list.searchKey = 'id,name,pjectId,createTimeString'
      list.actions.once = {
        name:'执行一次',
        action(event){
          let item = event.detail
          G.get('/v1/job/' + item.id,null,null,{ loading:true,timeout:10 * 60 * 1000 }).then(res => {
            G.alert(res.errorMsg ? '请在控制台中查看失败日志' : '执行成功')
            console.log(res)
          })
        }
      }
      list.actions.log = {
        name:'查询日志',
        action(event){
          let item = event.detail
          G.$go(`/pages/logs/logs?desoptions=${JSON.stringify({$regex:item.id})}`)
        }
      }
    },
    modeleditquery(edit,event,query){
      if(edit.values.file) edit.values.file = decodeURI(edit.values.file)
      edit.submit = function(data,query){
        if(data.file) data.file = encodeURI(data.file)
        return data
      }
    }
  },{
    data:{
      
    },
    mounted:function(query){
      // _this = this
    }
  }));
})(Y)
</script>
<style scoped>
  
</style>